package models

import (
	"go-admin/common/models"
	"gorm.io/gorm"
)

type SysTemplate struct {
	models.Model
	TypeId  int            `json:"typeId" gorm:"size:10;comment:模版类型"`
	Title   string         `json:"title" gorm:"type:varchar(64);comment:模版名称"`
	IsTpl   bool           `json:"isTpl" gorm:"size:2;comment:模版是否文件"`
	Content string         `json:"content" gorm:"size:128;comment:模版"`
	Remark  string         `json:"remark" gorm:"size:255;comment:备注"`
	Status  string         `json:"status" gorm:"size:4;comment:状态"`
	TypeIds []int          `json:"typeIds" gorm:"-"`
	Type    *SysMemberType `json:"type"`
	models.ControlBy
	models.ModelTime
}

func (SysTemplate) TableName() string {
	return "sys_template"
}

func (e *SysTemplate) Generate() models.ActiveRecord {
	o := *e
	return &o
}

func (e *SysTemplate) GetId() interface{} {
	return e.Id
}

func (e *SysTemplate) AfterFind(_ *gorm.DB) error {
	e.TypeIds = []int{e.TypeId}
	return nil
}
